package com.example.student.bean;

public class BaseResultBean {
    public static final int CODE_OK =200;
    public static final int CODE_SQL_FAIL =201;
    public static final int CODE_SERVER_FAIL =202;
    public static final int CODE_FAIL =203;
    public int code;//200正确
    public String msg;
    public Object data;

    public static BaseResultBean OK(Object data){
        BaseResultBean baseResultBean = new BaseResultBean();
        baseResultBean.code = CODE_OK;
        baseResultBean.msg = "ok";
        baseResultBean.data = data;
        return baseResultBean;
    }
    public static BaseResultBean OK(Object data,String msg){
        BaseResultBean baseResultBean = new BaseResultBean();
        baseResultBean.code = CODE_OK;
        baseResultBean.msg = msg;
        baseResultBean.data = data;
        return baseResultBean;
    }
    public static BaseResultBean SQL_fail(){
        BaseResultBean baseResultBean = new BaseResultBean();
        baseResultBean.code = CODE_SQL_FAIL;
        baseResultBean.msg = "数据库操作失败";
        baseResultBean.data = null;
        return baseResultBean;
    }
    public static BaseResultBean Server_fail(){
        BaseResultBean baseResultBean = new BaseResultBean();
        baseResultBean.code = CODE_SERVER_FAIL;
        baseResultBean.msg = "服务器异常";
        baseResultBean.data = null;
        return baseResultBean;
    }
    public static BaseResultBean fail(String msg){
        BaseResultBean baseResultBean = new BaseResultBean();
        baseResultBean.code = CODE_FAIL;
        baseResultBean.msg = msg;
        baseResultBean.data = null;
        return baseResultBean;
    }
}
